package thesis.bean;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

@ManagedBean
@RequestScoped
public class VerifyBean {

	private String message;
	
	public VerifyBean()
	{
		this.verifyUser();
	}
	
	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public void verifyUser()
	{
		try {
			HttpSession session = (HttpSession) FacesContext
					.getCurrentInstance().getExternalContext().getSession(true);
			if (session.getAttribute("user") != null) {
				UserBean userBean = (UserBean) session.getAttribute("user");
				if (userBean.loggedIn == true) {
					FacesContext.getCurrentInstance().getExternalContext().redirect("service.jsf");
				}
			}
		} catch (Exception e) {
		}
	}
	
	public void verifyLogged()
	{
		
	}
}
